<?
if(!isset($_SESSION)){session_start();};
require_once("core.php");
require_once("includes/array.in.php");
//define('INCLUDE_CHECK',true); //Check Login

$db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php echo DESCRIPTION;?>
<?php echo KEYWORD;?>
<meta name="author" content="PosterThailand.com" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo WEB_TITLE;?></title>
<link href="styles/style.css" rel="stylesheet" />
<link href="styles/ads.css" rel="stylesheet" />
<link href="styles/sweet_pagination.css" rel="stylesheet" />
<link type="text/css" href="styles/ui-lightness/jquery-ui-1.8rc2.custom.css" rel="stylesheet" />

<!-- StyleSheet Plugin-->

<script type="text/javascript" src="scripts/jquery/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="scripts/jquery/jquery-ui-1.8rc2.custom.min.js"></script>
<script type="text/javascript" src="scripts/jquery/sweet_pagination.js"></script>
<!-- Script Plugin -->



</head>

<body>
	<div class="page">
    
    	<?php require_once('header.php');?>
        
        <div class="content">
        	<div id="wrap_top">
            	<div id="wrap_top_left">
                	<div id="wrap_ads">                	 
                        <div id="wrap_728x90" class="shadow"><?php get_ads(2);?></div>
                	</div>
                    
                    <div class="clear" style="margin-left:15px;"></div>
                    
                    <div id="ads_300x250">
                    	<span id="ads_300x250_1" class="shadow"><?php get_ads(3);?></span>
                    	<span id="ads_300x250_2" class="shadow"><?php get_ads(4);?></span>
                    </div>
                    
                    
                    
                    <div id="special_ads">
                    	<div id="title"><h1>ประกาศตำแหน่งพิเศษ</h1></div>
                        <div class="clear"></div>
                    	<span id="sp_box">
                        	<div id="sp_img"><?php get_ads(5);?></div>
                            <div id="sp_title"></div>
                        </span>
                        <span id="sp_box">
                        	<div id="sp_img"><?php get_ads(6);?></div>
                            <div id="sp_title"></div>
                        </span>
                        <span id="sp_box">
                        	<div id="sp_img"><?php get_ads(7);?></div>
                            <div id="sp_title"></div>
                        </span>
                        <span id="sp_box">
                        	<div id="sp_img"><?php get_ads(8);?></div>
                            <div id="sp_title"></div>
                        </span>
                        <span id="sp_box">
                        	<div id="sp_img"><?php get_ads(9);?></div>
                            <div id="sp_title"></div>
                        </span>
                    </div>
                    
                                        
                    <div id="suggest_ads">
                    	<div id="title"><h1>ประกาศตำแหน่งแนะนำ</h1></div>
                        <div class="clear"></div>
                        <span id="sp_box">
                        	<?php get_ads(10);?>
                        </span>
                    	<span id="sp_box">
                        	<?php get_ads(11);?>
                        </span>
                        <span id="sp_box">
                        	<?php get_ads(12);?>
                        </span>
                        <span id="sp_box">
                        	<?php get_ads(13);?>
                        </span>
                        <span id="sp_box">
                        	<?php get_ads(14);?>
                        </span>
                        <span id="sp_box">
                        	<?php get_ads(15);?>
                        </span>
                    	<span id="sp_box">
                        	<?php get_ads(16);?>
                        </span>
                        <span id="sp_box">
                        	<?php get_ads(17);?>
                        </span>
                        <span id="sp_box">
                        	<?php get_ads(18);?>
                        </span>
                        <span id="sp_box">
                        	<?php get_ads(19);?>
                        </span>
                    </div>
                                        
                </div>
                <div id="wrap_top_right">
                	<div id="sub_title">หมวดหมู่สินค้า</div>
                    <div class="clear"></div>
                	<?php
                    $q = $db->select_query('SELECT * FROM '._CATEGORY); 
					
					echo '<ul class="catlist">';					
					while ($r = $db->fetch($q)) { 
						if($r['cat_name']!=""){
					?>					
                    	<li><a href="products/?m=categories&p=categories&cid=<?php echo $r['cat_id'];?>&c=<?php echo $r['cat_name'];?>">&raquo; <?php echo $r['cat_name'];?></a></li>                   	                      
					<?php
						}
					}
					echo '</ul>';
					?>
                    <iframe src="http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2FPosterthailand-fanpage%2F178290318853273&amp;width=230&amp;colorscheme=light&amp;connections=6&amp;stream=false&amp;header=true&amp;height=287" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:230px; height:287px;" allowTransparency="true"></iframe>
                </div>
            </div>
            

            
            <div id="wrap_bottom">
            	<div id="wrap_bottom_left">
                	<div id="title"><h1>Update ประกาศล่าสุด</h1></div>
                    <div class="clear"></div>
                    <ul id="holder" >
                    <?php
                    $sql = "SELECT
								  `products`.*, `products_img`.`img1`, `category`.`cat_name`
								FROM
								  `products` INNER JOIN
								  `products_img` ON `products`.`pid` = `products_img`.`pid` INNER JOIN
								  `category` ON `products`.`cat_id` = `category`.`cat_id`								
								GROUP BY
								  `products`.`pid`
								ORDER BY
								  `products`.`p_change_place` DESC, `products`.`p_create` DESC
								LIMIT 0, 100";
					$get_cat_q = $db->select_query($sql);
					$even = "even";
					while($show_post = $db->fetch($get_cat_q)){
						if($show_post['cat_name']!=""){
						$even_odd = ($even != "even")? 'class="odd"' : 'class="even"'; 
						($even == "odd")? $even = "even" : $even = "odd" ;
					?>
                    <li>
                    <div id="post" <?php echo $even_odd; ?>>
                    	<div id="post_img"><img src="<?php echo 'uploads/'.$show_post['img1'];?>" /></div>
                        <div id="post_title">
	                   		<div id="post_header">
                            	<a href="<?php echo WEB_URL.'/products/?m=products&p=product_detail&pid='.$show_post['pid'];?>"><?php echo $show_post['p_title'];?></a> 
                                <span id="price">฿ <?php ($show_post['p_sure_price'] != 0)? print $show_post['p_sure_price'].'.-': print $show_post['p_price'];?> 
								<?php 
									$p_created = (int)date('d',strtotime($show_post['p_create']));
									$today = date('d',time());
									if($p_created == $today){
										echo '<img src="styles/images/icon_new.gif" align="absmiddle" alt="'.$show_post['p_title'].'" />';
									}?>
                                </span>                                
                          	</div>
                            <div class="short-desc">
								<?php echo strip_tags(iconv_substr($show_post['p_detail'],0,240,'utf-8')).'...'; ?>
                            </div>
	                        	<span id="post_cat">Category :  <a href="<?php echo WEB_URL.'/products/?m=categories&p=categories&cid='.$show_post['cat_id'].'&c='.$show_post['cat_name'];?>"><?php echo $show_post['cat_name'];?></a></span> | <span id="post_dat"> Date Poste : <?php echo ThaiTimeConvert(strtotime($show_post['p_create']),0,1);?></span>            
	                	</div> 
                    </div>
                    <div id="dot"></div>
                    </li>
                    <?php
						}
					}
					?>
                 </ul>   
                </div>
                
                <?php require_once('wrap_bottom_right.php');?>
            </div>
        </div>
        
        <?php require_once('footer.php'); ?>
        
    </div>
</body>
</html>